//
//  LoginViewController.swift
//  SwiftIM
//
//  Created by WuZhijian on 14/12/6.
//  Copyright (c) 2014年 com.liveln. im. All rights reserved.
//

import UIKit

class LoginViewController: UIViewController {

    @IBOutlet weak var doneButton: UIBarButtonItem!
    @IBOutlet weak var username: UITextField!
    @IBOutlet weak var password: UITextField!
    
    //需要登陆
    var requireLogin = false
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
        if sender as UIBarButtonItem == self.doneButton {

            //用户名和密码
            NSUserDefaults.standardUserDefaults().setObject(username.text+"@im.livelu.cn", forKey: "weixinID")
            NSUserDefaults.standardUserDefaults().setObject(password.text, forKey: "weixinPWD")
            //自动登陆
            
            //同步用户配置
            NSUserDefaults.standardUserDefaults().synchronize()
            
            //需要登陆
            requireLogin = true
        }
    }
    

}
